package com.zxm.util;

import java.util.*;

/**
 * 集合工具类
 */
public class ConnectionUtil {

    /**
     * 将map中的key按照顺序进行排序
     */
    public static Map<Integer,Integer> sortMap( Map<Integer,Integer> myMapTmp){
        Map<Integer,Integer> myMap = new LinkedHashMap<Integer,Integer>();

        List<Integer> keyList = new ArrayList<Integer>();
        Iterator<Integer> it =myMapTmp.keySet().iterator();
        while(it.hasNext()){
            keyList.add(it.next());
        }
        Collections.sort(keyList);
        Iterator<Integer> it2 = keyList.iterator();
        while(it2.hasNext()){
            Integer key = it2.next();
            myMap.put(key, myMapTmp.get(key));
        }
        return  myMap;
    }
}
